<?php
//dezend by http://www.yunlu99.com/ QQ:270656184
defined('BASEPATH') || exit('No direct script access allowed');
class Record extends MY_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->verify_user();
	}

	public function index()
	{
		$coin_id = intval(get_cookie('coin_id'));

		if ($coin_id <= 0) {
			$d['coin'] = $this->db->get('coin')->row_array();
		}
		else {
			$d['coin'] = $this->db->where('id', $coin_id)->get('coin')->row_array();
		}

		$where = 'coin_id=' . $coin_id . ' and (buy_user_id=' . $this->session->user_id . ' and sell_user_id=' . $this->session->user_id . ')';
		$result = $this->result_list(array('table' => 'deal', 'where' => $where, 'url' => 'record/index', 'order' => 'add_time desc', 'per_page' => 10));
		$d['page'] = $result['page'];
		$list = $result['list'];

		foreach ($list as $k => $v) {
			if ($v['buy_user_id'] == $this->user['id']) {
				$list[$k]['type'] = '买入';
			}
			else {
				$list[$k]['type'] = '卖出';
			}
		}

		$d['list'] = $list;
		$this->show(array('header', 'user_left', 'record', 'footer'), $d);
	}
}

?>
